CXX = g++
CC = gcc
GECKO_SDK = /usr/lib/xulrunner-1.9
GECKO_CONFIG_INCLUDE = -include xpcom-config.h

GECKO_INCLUDES = -I$(GECKO_SDK)/include  `nspr-config --cflags`

GECKO_CXXFLAGS = $(GECKO_INCLUDES) $(GECKO_CONFIG_INCLUDE) \
		 -g -Wall -fPIC -fshort-wchar

GECKO_LDFLAGS = -shared -L $(GECKO_SDK)/lib -Wl,-z,defs -lxpcomglue_s -lxpcom -lnspr4 -ldl `nspr-config --libs`

all: idl-header idl-xpt onlylyric.so

idl-header: onlylyric.h

idl-xpt: onlylyric.xpt


onlylyric.so: onlylyric-module.o \
	Lrc.o PlayerManager.o  \
	SearchLrcInDir.o \
	onlylyric-impl.o \
	tellenc.o \
	MapLrcFile.o \
	XmmsPlayer.o \
	MpdPlayer.o \
	libmpdclient.o \
	CharsetConvert.o
	$(CXX) -o $@ $^ $(GECKO_LDFLAGS) 

%.o: %.c
	$(CC) -c $(GECKO_CXXFLAGS) $<

%.o: %.cpp
	$(CXX) -c $(GECKO_CXXFLAGS) $<

%.xpt: %.idl
	$(GECKO_SDK)/bin/xpidl -I $(GECKO_SDK)/idl -m typelib $<

%.h: %.idl
	$(GECKO_SDK)/bin/xpidl -I $(GECKO_SDK)/idl -m header $<

clean:
	-rm -rf  *.xpt *.o *.so *.lo *.la .libs .deps
	-rm onlylyric.h
allclean:
	$(MAKE) clean
